<template>
  <div class="login_warpper">
    <div class="form_warpper">
      <div class="form">
        <p class="form-item">
          <span class="label">姓名：</span>
          <el-input type="text" v-model="name" />
        </p>
        <p class="form-item">
          <span class="label">账号：</span>
          <el-input type="text" v-model="account" />
        </p>
        <p class="form-item">
          <span class="label">密码：</span>
          <el-input type="password" v-model="password" />
        </p>
        <el-button type="primary" @click="login">登录</el-button>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
// import socket from "@/socket"
import router from "@/router";
const usersStore = useUsersStore();
const name = ref("张三");
const account = ref("admin");
const password = ref("123456");
const login = async () => {
  const params = {
    account: account.value,
    password: password.value,
  };
  const res = await usersStore.login(params, name.value);
  if (!res) {
    return ElNotification({
      title: "错误",
      message: "账号或密码错误",
      type: "error",
    });
  }
  router.push("/chat");
};
</script>

<style lang="scss" scoped>
@property --angle {
  syntax: "<angle>";
  inherits: true;
  initial-value: 0deg;
}
.login_warpper {
  width: 100%;
  height: 100vh;
  background-color: #000;
  display: flex;
  justify-content: center;
  align-items: center;
  .form_warpper {
    width: 416px;
    height: 316px;
    position: relative;
    background-image: linear-gradient(var(--angle), aqua 0%, #f58cde 100%);
    animation: rotate 3s linear infinite;
    border-radius: 5px;
    box-shadow: 0 0 10px #fff;
    @keyframes rotate {
      0% {
        --angle: 0deg;
      }
      100% {
        --angle: 360deg;
      }
    }
    .form {
      width: 400px;
      height: 300px;
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
      background-image: linear-gradient(
        90deg,
        rgb(141, 225, 225) 0%,
        #621451 100%
      );
      border-radius: 5px;
      padding: 12px;
      box-sizing: border-box;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      color: #fff;
      .form-item {
        display: flex;
        margin-bottom: 20px;
        width: 100%;
        .label {
          width: 60px;
          display: flex;
          justify-content: flex-end;
          align-items: center;
        }
      }
      .el-button {
        width: 100%;
        height: 40px;
        font-size: 18px;
      }
    }
  }
}
</style>
